package me.boot.web.common.template.controller;

import cn.hutool.core.bean.BeanUtil;
import me.boot.common.context.ContextUtil;
import me.boot.common.data.model.UserInfo;
import me.boot.db.mybatis.template.SuperService;
import me.boot.db.mybatis.template.entity.Entity;

import java.io.Serializable;

public interface BaseController<
        ID extends Serializable,
        PO extends Entity<ID>,
        S extends SuperService<ID, PO>> {

    Class<PO> getPoClass();

    S getService();

    default UserInfo getSessionUser() {
        return ContextUtil.getUser();
    }

    default PO dtoToPo(Object dto) {
        return BeanUtil.toBean(dto, getPoClass());
    }

}
